//
//  LocalAndCallCell.m
//  diaoyuren
//
//  Created by 钓鱼人 on 16/3/3.
//  Copyright © 2016年 game. All rights reserved.
//

#import "LocalAndCallCell.h"
#import "UILabel+BoundRect.h"
@interface LocalAndCallCell ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *ImgHight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *ingWidth;


@property (weak, nonatomic) IBOutlet NSLayoutConstraint *linHight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textLeft;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textRight;
@end

@implementation LocalAndCallCell

- (void)awakeFromNib {
    self.ImgHight.constant = 30;
    self.ingWidth.constant = 30;
    
    self.textLeft.constant = 10;
    self.textRight.constant = 0;
    
    self.linHight.constant = 0.5;
    
    self.text.numberOfLines = 0;
    self.text.font = font(SCREEN_WIDTH*0.045);
    
    /**
     *  设置图片的填充模式
     */
    self.imgView.contentMode =4;
    self.selectionStyle  = UITableViewCellSelectionStyleNone;
    self.accessoryType = 1;

}

-(void)setTextString:(NSString *)textString{

    _textString = textString;
    
    self.imgView.alpha = 1;
    self.accessoryType = 1;
    
    NSMutableString *str = [[NSMutableString alloc] initWithString:_textString];
    NSArray *arr = [str componentsSeparatedByString:@","];
    NSString *string = [arr componentsJoinedByString:@"  "];
    self.text.text = string;
    
  //tableview右边自带箭头宽度
    CGFloat subtract = 33;
    if (kDIEIsIPhone6P) {
        subtract = 38;
    }
    
    CGFloat ww = SCREEN_WIDTH-(self.ingWidth.constant+self.textLeft.constant+self.textRight.constant+8+subtract);
    CGRect rect =[self.text boundingRectWithInitSize:CGSizeMake(ww, 0)];
    self.cellHight = rect.size.height+20;
    
    if (_textString.length==0) {
        self.imgView.alpha = 0;
        self.cellHight =  -1;
         self.accessoryType = 0;
    }
    
}

@end
